package org.maitaole.bean;

import java.time.LocalDateTime;

// 验证码
public class ValidateCode {
    private String text;
    private LocalDateTime expire; // 过期时间

    /**
     * @param text      是图片验证的码的文字
     * @param duration   验证有效时长
     */
    public ValidateCode(String text, long duration) {
        this.text = text;
        // 图片验证的失效时间
        this.expire = LocalDateTime.now().plusSeconds(duration);
    }

    // 是否过期
    public boolean isExpire() {
        return LocalDateTime.now().isAfter(expire);
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public LocalDateTime getExpire() {
        return expire;
    }

    public void setExpire(LocalDateTime expire) {
        this.expire = expire;
    }
}
